<template>
	<view class="user">
		<view class="top">
			<image src="../../static/images/history.png" mode=""></image>
			<view class="text">
				浏览历史
			</view>
		</view>
		
		<view class="content">
			<view class="row" v-for="item in listArr">
				<newsbox :item="item" @click.native="goDetail(item)"></newsbox>
			</view>
		</view>
		
		<view class="nohistory" v-if="listArr.length === 0">
			<image src="../../static/images/nopic.jpg" mode="widthFix"></image>
			<view class="text">
				暂无浏览记录
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				listArr:[]
			}
		},
		onShow(){
			this.getData()
		},
		methods: {
			// 跳转到详情页面
			goDetail(){
				uni.navigateTo({
					url:`/pages/detail/detail?cid=${item.class}&id=${item.id}`,
					
				})
			},
			//	获取缓存
			getData(){
				let historyArr =  uni.getStorageSync("historyArr") || []
				this.listArr = historyArr
			}
			
			
			
			//
		}
	}
</script>

<style lang="scss" scoped>
	.user{
		.top{
			padding: 50rpx 0;
			background: #F8F8F8;
			color: #555;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			image{
				width: 150rpx;
				height: 150rpx;
			}
			.text{
				font-size: 38rpx;
				padding-top: 20rpx;
			}
		}
		.content{
			padding: 30rpx;
			.row{
				border-bottom: 1px dotted #efefef;
				padding: 15rpx 0rpx;
			}
		}
		.nohistory{
			display: flex;
			justify-content: center;
			align-items: center;
			flex-direction: column;
			img{
				width: 400rpx;
			}
			.text{
				font-size: 26rpx;
				color: #888;
			}
		}
		//
	}
</style>
